﻿#ifndef ANDYRP_COMMON_INCLUDED
#define ANDYRP_COMMON_INCLUDED
#include "Packages/com.unity.render-pipelines.core/ShaderLibrary/Common.hlsl"

#include "UnityInput.hlsl" 

float3 TransformObjectToWorld(float3 positionOS)
{
	return mul(unity_ObjectToWorld, float4(positionOS,1)).xyz;
}

float4 TransformObjectToHClip(float3 positionWS)
{
	return mul(unity_MatrixVP, float4(positionWS,1));
}

float4x4 GetObjectToWorldMatrix()
{
	return UNITY_MATRIX_M;
}

float3 TransformObjectToWorldNormal(float3 normalOS)
{
#ifdef UNITY_ASSUME_UNIFORM_SCALING
	return TransformObjectToWorldDir(normalOS);

#else
	return SafeNormalize(mul(normalOS, (float3x3)GetObjectToWorldMatrix()));
#endif
}

float3 TransformObjectToWorldDir(float3 dirOS)
{
	return SafeNormalize(mul((float3x3)GetObjectToWorldMatrix(),dirOS));
}

#endif